POV-Ray : Newsgroups : povray.advanced-users : movie within : Re: movie within Server Time
29 Jul 2024 06:18:26 EDT (-0400)
  Re: movie within  
From: Warp
Date: 4 Feb 2004 10:57:41
Message: <40211675@news.povray.org>
Dan P <dan### [at] yahoocom> wrote:
> I believe my 15 years of studying and
> programming experience will come in quite handy.

  If 15 years of programming experience causes you to make programs with
the quality of the one you posted at the beginning of this thread, I find
that quite amazing.
  No offence, but the program looked like made by someone who has started
learning programming a month ago.

> Warp, I didn't argue with you about your coding styles because I didn't want
> to get into a fight over something that is largely a matter of style. For
> example, even though I used global variables, it makes it easier to take
> that program and put it into a class that way -- I wouldn't have to change
> all the references in the code so they were no longer in a struct when I
> encapsulate it.

  What I wonder is why you didn't create a class to start with. The fact
that the program is small is a lousy excuse to make it horrible, specially
if you are going to post it in public. If someone learning programming were
to study your code and enhance it he may well learn really bad habits and
get himself into trouble. In fact, by doing this you are learning bad
habits yourself.

> Putting error handling before putting success handling is
> very odd and makes the code harder to read (some people have that goal,
> though), in my opinion, but I respected your style.

  I don't understand how it is easy to read that you open a file and
handle its failure tens of lines later. The error handling was hard
to find and it was hard to associate with the line where the file was
opened.

  When opening a file success means that the program can continue normally.
That is, it doesn't have to interrupt its normal flow. Only failure means
that it needs to stop its normal flow.
  That is, the code is clear if it does something like this:

- Open the file.
- Did opening fail? If so, issue an error.
- Read the file.

  In your case what you are writing is this:

- Open the file.
- Read the file.
- Did opening fail? If so, issue an error.

  It makes no sense to keep the success check separated from the opening.

  Besides, by doing it that way you are needlessly introducing an extra
level of block nesting. The more nested blocks you have, the harder it
is to read the code.

> Casting a pointer to
> (void *) when freeing is actually a common practice and if you widened your
> experience with C you'd see a lot of other people use it.

  I have been programming C probably longer than you, and I don't remember
seeing anyone casting to void* to free memory. There's no need, it doesn't
make sense, and it's in fact dangerous.
  Consider this:

int a = 5;
free((void*)a);

  Kaboom?
  The compiler does not issue an error message, not even a warning. However,
the program will most probably crash.
  Granted, in this case it's easy to see what's wrong, but in a much longer
program a mistake like that can be pretty hard to find.

  If you, however, make "free(a)" the compiler will issue an error message.

  So I'm sorry, but you are simply wrong.

> I put fflush() in
> there because I'm in the habit of flushing buffered streams -- habit -- let
> me say that again, -- habit -- and so it was something I typed
> automatically.

  Not all habits are good.
  Certainly if you use fflush() too much when not needed you are only making
a slower program for no reason.

> Returning 0 instead of EXIT_SUCCESS is also standard, and if
> you learned C when I did from the K&R book, you'd know that too.

  No it isn't.
  There's nothing in the C standard that says that 0 is the return code
for success. The return code for success is system-dependant and that's
why EXIT_SUCCESS should be used instead. That's why EXIT_SUCCESS and
EXIT_FAILURE exist in the first place.

> But, you
> know what, I didn't want to make you look bad because your way of doing
> things works as well and it is a matter of personal preference.

  You seem to have this odd arrogant attitude. Don't you understand that
by trying so badly to make yourself sound competent you are only making
a fool of yourself?

> Your coding
> style is not the /RIGHT/ coding style, it is /YOUR/ coding style, Warp. If
> you were argue /RIGHT/ coding style, then according to the fathers of C, I'm
> actually closer to it than you.

  Yeah, I'm sure that the "fathers of C" suggest that you use tons of
global variables, never check the validity of input data, index out of
boundaries in tables (such as argv[]), read data to static buffers without
limits and make system-dependant code.

  Perhaps you should read the latest C standard and some good programming
design book.

> As far as including variables I don't use, like the version, and the static
> insecure char buffers, that was there for the same reason I didn't check the
> command-line arguments -- I wrote it for personal use to put together an
> animation quickly for a project I was working on and if I wanted to refine
> the code to release to the public on a board like you did, I certainly would
> have checked for those parameters.

  But you didn't add the checks, yet you still published the code in
a public forum. Yeah, sure.

> I understand that you're a perfectionist
> about these things, but I'm more goal-driven than yourself, and the goal was
> create motion-blur, and the goal of the post was to demonstrate how to do it
> with sample code, not impress you. I understand how you might find that hard
> to imagine.

  What I find hard to imagine is that someone who allegedly has 15 years of
programming experience can make such crappy code and isn't even embarassed
to post it in a public forum full of programmers.

> Now, I have too much class to download your targa averager and nitpick over
> your coding style and say it is wrong to a group of your peers. That would
> be disrespectful and naive. When you get more experience working on
> projects, you'll understand.

  Now you are being incredibly hypocritical. You explicitly ASKED ME to
comment on your code. Initially I did not, but then you asked so I did.
Now you are talking as if I had given you comments you didn't ask and
weren't interested in.

  As for my averager program, the code is crappy. I wrote it 6 years ago
and I certainly did not have as much experience as today. If I were to
write the same program again, it would certainly look completely different.
  I could better ask you to look at my newer code, but seeing your real
programming skills and your state of mind that would be only a waste of
time and resources since I will not be getting anything constructive.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.